#pragma once

#include "export.h"
#include "vec.h"
#include "node.h"
#include "camera.h"
#include "manipulator.h"
#include <string>
#include <osg/Camera>
#include <osgViewer/Viewer>
#include <osgGA/MatrixManipulator>

//----------------------------------------------------------------------
class DENG_EXPORT Viewer 
//----------------------------------------------------------------------
{
public:
           Viewer( long hwnd = 0 );
  virtual ~Viewer(void);
  void     Frame() { _viewer->frame(); };
  void     Run()   { _viewer->run();   };

  void     SetRoot(Node *n);  
  Node*    GetRoot();
  double   Time() {return osg::Timer::instance()->delta_m(_t0, osg::Timer::instance()->tick() ); };

  //Camera*       GetCamera()       {return _camera;};
  Manipulator*  GetManipulator()  {return _manip;};

  void SetBackground(Vec color) { _viewer->getCamera()->setClearColor(color.GetCol());};
  Vec  GetBackground()          { return _viewer->getCamera()->getClearColor(); };

  void  SetFov(double fov);
  double GetFov();

protected:
  osg::ref_ptr<osgViewer::Viewer> _viewer;
  osg::ref_ptr<osg::Camera> _camera;
  osg::Timer_t _t0;
  
  Node*        _root;
  //Camera*      _camera;
  Manipulator* _manip;
};

